<%@page import="cn.ysnk.clz.entity.menu.AdminMenu"%>
<%@page import="cn.ysnk.clz.entity.menu.AdminSubMenu"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%
AdminSubMenu subMenu = null;
String menuId = (String)request.getAttribute("menuId");
String subMenuId = (String)request.getAttribute("subMenuId");
if(subMenuId!=null){
	subMenu = AdminSubMenu.adminSubMenuDao.findById(subMenuId);
	System.out.println(subMenu);
}
AdminMenu menu = AdminMenu.adminMenuDao.findById(menuId);
%>
</head>
<body>
	<script type="text/javascript">
			$(function(){
				var isCanSubmit = 1;
				jQuery("#editSubMenuForm").validationEngine(
				'attach',
				{
					promptPosition : "topLeft",
					onSuccess : function() {
						if (isCanSubmit == 1) {
							jQuery("#editSubMenuForm").submit();
							isCanSubmit++;
						}
				    }
			    });
			});
			function checkForm(){
				if($("#editSubMenuForm").validationEngine("validate")){
					if($.trim($("#iconName").val())==""){
						$("#iconShow").validationEngine("showPrompt","请选择图标","error");
					}else{
						ajaxFormPost("/adminMenu/saveSubMenu","editSubMenuForm",refreshAdmin,refreshAdmin);
 					}
				}
			}
		</script>
	<div class="container">
		<div class="page-header">
          <h2><%=subMenu==null?("新增“"+menu.getStr("name")+"”的子菜单"):"编辑“"+menu.getStr("name")+"”的子菜单" %></h2>
        </div>
	   	<form class="form-horizontal" id="editSubMenuForm" method="post" action="<%=request.getContextPath()%>/adminMenu/saveMenu">
	   	<input type="hidden" name="menuId" value="<%=menuId %>"/>
	   	<input type="hidden" name="subMenuId" value="<%=subMenuId==null?"":subMenuId %>"/>
		  <div class="form-group">
		    <label for="name" class="col-sm-2 control-label">菜单名称：</label>
		    <div class="col-sm-10">
	    		<input style="display:none"><!-- for disable autocomplete on chrome -->
		      	<input  universal-class="validate[required,maxSize[7]]"  autocomplete="off" type="text" class="form-control" value="<%=subMenu==null?"":subMenu.getStr("name") %>" id="name" name="menuname" placeholder="菜单名称">
		    </div>
		  </div>
		  <div class="form-group">
		    <label for="icon" class="col-sm-2 control-label">图标：</label>
		    <div class="col-sm-10">
		    <input type="hidden" name="iconName" id="iconName" value="<%=subMenu==null?"":subMenu.getStr("icon") %>"/>
		    <%
		    if(subMenu==null){
				%>
		    	<div id="iconShow" name="iconShow"  class="inline-block">无</div>
		    	<%
		    }else{
		    	%>
		    	<div id="iconShow" name="iconShow"  class="inline-block">
		    		<span class="glyphicon glyphicon-<%=subMenu.getStr("icon") %>" aria-hidden="true"></span><span>glyphicon-<%=subMenu.getStr("icon") %></span>
		    	</div>
		    	<%
		    }
		    %>
		    <a href="<%=request.getContextPath() %>/admin/chooceIcon" class="btn btn-default" data-toggle="modal" data-target="#myModal">选择图标</a>
		    </div>
		  </div>
		  <div class="form-group">
		    <label for="sort" class="col-sm-2 control-label">序号</label>
		    <div class="col-sm-10">
		      <input type="text" universal-class="validate[required,custom[zhenginteger],maxSize[3]]" name="sort" value="<%=subMenu==null?"1":subMenu.getInt("sort") %>" class="form-control" id="sort" placeholder="">
		      <p class="text-primary default-padding ">注意：序号决定菜单在菜单栏显示的先后顺序</p>
		    </div>
		  </div>
		  <div class="form-group">
		    <label for="menuAction" class="col-sm-2 control-label">菜单动作：</label>
		    <div class="col-sm-10">
	    		<input style="display:none"><!-- for disable autocomplete on chrome -->
		      	<input universal-class="validate[required,maxSize[100]]" autocomplete="off" type="text" class="form-control" value="<%=subMenu==null?"":subMenu.getStr("action") %>" id="menuAction" name="menuAction" placeholder="菜单动作">
		      	<p class="text-primary default-padding ">请填写点击菜单的动作如：/adminMenu/manage</p>
		    </div>
		  </div>
		  <div class="form-group">
		    <div class="col-sm-offset-2 col-sm-10">
		      <button type="button" onclick="checkForm();" class="btn btn-primary">保存</button>
		      <button type="button" onclick="menuback()" class="btn btn-default">返回</button>
		    </div>
		  </div>
		</form>
	</div>
</body>

</html>